<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta charset="UTF-8">
		<title>共富网-红包 </title>
		<link href="/game/redpack/css/redPacket.css" type="text/css"
		rel="stylesheet" />
		<script src="/v3/js/jquery-1.10.2.min.js"></script>
		<script src="/game/redpack/js/jquery.hbalerts.js" type="text/javascript"></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script type="text/javascript" src="/v3/js/wechat-util.js"></script>

<script type="text/javascript">
$(function() {
	if(!wechatUtil.is_weixin()){ 
		window.location.href = "/error/weixin.jsp";
	}
	wechatUtil.config( [ 'showOptionMenu','onMenuShareAppMessage','onMenuShareTimeline' ]);
});
var _imgsrc = "http://m.gofull.com.cn/game/redpack/images/arrow_bg.jpg";
var title_ = '';

function checkForm() {
		var eliteAmount = Number($('#eliteAmount').val());
		if ($('#num').val() == '') {
			jAlert("红包个数不能为空", '提示信息');
			return false;
		}
		if (isNaN($('#num').val())) {
			jAlert("红包个数必须为整数", '提示信息');
			//$('#num').focus();
			return false;
		}
		if ($('#num').val() <= 0) {
			jAlert("红包个数必须大于0", '提示信息');
			return false;
		}
		/*
		if ($('#num').val() > 100) {
			jAlert("红包个数不能大于100", '提示信息');
			return false;
		}*/

		if ($('#totalflow').val() == '') {
			jAlert("红包必须为整数", '提示信息');
			//$('#totalflow').focus();
			return false;
		}
		if (isNaN($('#totalflow').val())) {
			jAlert("红包必须为整数", '提示信息');
			//$('#totalflow').focus();
			return false;
		} else if ($('#totalflow').val() <= 0) {
			jAlert("红包必须大于0", '提示信息');
			//$('#totalflow').focus();
			return false;
		}else if ($('#totalflow').val() > eliteAmount){
			jAlert("体验金金额不足", '提示信息');
			//$('#totalflow').focus();
			return false;
		}
		if ($('#packtype').val() == 1) {
			tf = $('#totalflow').val() * $('#num').val();
			/*
			if ($('#totalflow').val() > 5000) {
				jAlert("单个红包不能大于5000元", '提示信息');
				return false;
			}*/
		} else {
			if (parseInt($('#num').val()) > parseInt($('#totalflow').val())) {
				jAlert("红包总额必须大于或等于红包个数", '提示信息');
				//$('#totalflow').focus();
				return false;
			}
			tf = $('#totalflow').val();
			/*
			if ($('#totalflow').val() > 50000) {
				jAlert("红包总额不能大于50000元", '提示信息');
				return false;
			}*/
		}
		$('#createllredpack').submit();
}
	function checknum() {
		if ($('#num').val() == '') {
			jAlert("红包个数不能为空", '提示信息');
			return false;
		}
		if (isNaN($('#num').val())) {
			jAlert("红包个数必须为整数", '提示信息');
			//$('#num').focus();
			return false;
		}
		if ($('#num').val() <= 0) {
			jAlert("红包个数必须大于0", '提示信息');
			return false;
		}
		/*
		if ($('#num').val() > 100) {
			jAlert("红包个数不能大于100", '提示信息');
			return false;
		}*/

	}
	function checktotalflow() {
		checknum();
		if ($('#totalflow').val() == '') {
			jAlert("红包不能为空", '提示信息');
			return false;
		}
		if (isNaN($('#totalflow').val())) {
			jAlert("红包必须为整数", '提示信息');
			//$('#totalflow').focus();
			return false;
		} else if ($('#totalflow').val() <= 0) {
			jAlert("红包必须大于0", '提示信息');
			//$('#totalflow').focus();
			return false;
		}
		if ($('#packtype').val() != 1) {
			/*
			if ($('#totalflow').val() > 5000) {
				jAlert("单个红包不能大于5000元", '提示信息');
				return false;
			}*/
		} else {
			if (parseInt($('#num').val()) > parseInt($('#totalflow').val())) {
				jAlert("红包总额必须大于或等于红包个数", '提示信息');
				//$('#totalflow').focus();
				return false;
			}
			/*
			if ($('#totalflow').val() > 50000) {
				jAlert("红包总额不能大于50000元", '提示信息');
				return false;
			}*/
		}
	}
	$(function() {

		$("#box1").click(function() {
			var url = '';
			if (url != '') {
				location.href = url;
			} else {
				$('.liebiaophone').show();
				$('.liebiaodisplaynone').hide();
				$("#box2").removeClass('cls2');
				$("#box1").addClass('cls1');
				$(".liebiaoTrue1").show();
				$(".liebiaoTrue2").hide();
			}
		});

		box2.onclick();
		$("#createllredpack input[type='text']")
				.bind(
						'input propertychange',
						function() {
							if ($('#totalflow').val() != '') {
								$('#butdiv').attr("class",
										"rEaside rEasideTrue");
								$('#butdiv')
										.html(
												'<a href="javascript:;" onclick="checkForm()">塞进红包__tag_225$62_');
							} else {
								$('#butdiv').attr("class", "rEaside");
								$('#butdiv').html(
										'__tag_229$11_塞进红包__tag_229$38_');
							}
						})
	});
</script>
	</head>
	<body class="yshairMainTop">
	<div class="wztkjPopUpBox" style="display:none;">
		<div class="wztkjPopUpBoxMain">
			<div class="wztkjPopUpBoxContent1">
				<img src="/game/redpack/images/popUpBoxMark_03_06.png" />
			</div>
			<div class="wztkjPopUpboxBg">
				<div class="wztkjPopUpBoxContent2"></div>
				<div class="wztkjPopUpBoxContent3">
					<p class="wztkjPopUpboxP">取消</p>
					<p class="wztkjPopUpboxP1">确定</p>
					<div style="display:none;"></div>
				</div>
				<div class="wztkjPopUpBoxContent4" style="display:none;">确定</div>
			</div>
		</div>
		</div>

		
		<div class="robAfterMain useRMain">
		<form action="createllredpack.do" namespace="/" method="post"
			data-enhance="false" data-ajax="false" id="createllredpack">
			<input type="hidden" name="packtype" value="1" id="packtype"/>
			<input type="hidden" name="eliteAmount" value="${availableEliteMap.amount }" id="eliteAmount"/>
			<div class="wztSurplusTop">
				<div class="wztSurplusNumber">体验金余额:<span class="useRname">${availableEliteMap.amount }</span>元</div>
                <div class="wztSurplus-plin">&nbsp;&nbsp;</div>
				<ul id="box" class="reEselecttit">							
					<li id='box1' class="cls1"> 普通红包</li>
					<li id='box2' >手气红包</li>
					<div style="clear:both;"></div>
				</ul>
				<div class="liebiaophone" style="display:">
					<div class="rebodyinput1">
						<span class="liebiaophonespan">红包个数</span>
						<input type="text" name="num" id="num" placeholder="填写个数" maxlength="3" value="" />
						<em>个</em>
						<div style="clear:both;"></div>
					</div>
					<div class="rebodyinput1">
						<span class="redEnjia liebiaophonespan harEredEnjia" id="dgll"  style="display:block;">单个红包</span>
						<span class="redEnjia liebiaophonespan harEredEnjia" id="zll"  style="display:none;">红包总额</span>
						<input type="text" name="totalflow"
						onBlur="checktotalflow()" id="totalflow"  maxlength="5" placeholder="填写体验金" />
						<em>元</em>
						<div style="clear:both;"></div>
					</div>
                    <div class="rebodyinput1 new-rebodyinput">
						<input type="text" name="blessing" placeholder="恭喜发财，红包快来抢！" maxlength="30" id="blessing" />
						<div style="clear:both;"></div>
					</div>
				</div>
				<div class="wxAlertCMBotton wxAlertCMBottonRest">
					<p  onclick="checkForm()">塞进红包</p>
				</div>
			</div>
			</form>
		</div>
		<div class="robAfterBintbBottom useRBottom">
			<a href="/myredpacklist.do" class="robAfterMbBintContent">查看我的红包</a>
		</div>	
		
<script type="text/javascript">
			var box = document.getElementById("box");
			var box1 = document.getElementById("box1");
			var box2 = document.getElementById("box2");
			var dgll = document.getElementById("dgll");
			var zll = document.getElementById("zll");
			box1.onclick = function(){
				if (dgll.style.display=='none') {
					dgll.style.display='block';
				}
				if (zll.style.display=='block') {
					zll.style.display='none';
				}
				$("#box2").removeClass('cls2');
				 $("#box1").addClass('cls1');
				 document.getElementById('packtype').value="1";
				
			}
			box2.onclick = function(){
				if (zll.style.display=='none') {
					zll.style.display='block';
				}
				if (dgll.style.display=='block') {
					dgll.style.display='none';
				}
				$("#box1").removeClass('cls1');
				$("#box2").addClass('cls2');
				document.getElementById('packtype').value="2";
			}
					
			$(".wztkjPopUpboxP").click(function(){
				$('.wztkjPopUpBox').hide();
			});
			$(".wztkjPopUpboxP").click(function(){
				$('.wztkjPopUpBox').hide();
			});
			$(".wztkjPopUpboxP1").click(function(){
				$('.wztkjPopUpBox').hide();
			});
</script>	
		
		
</body>
</html>